package com.ruoyi.airspaceFlight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;


import com.ruoyi.airspaceFlight.dto.resp.ReleaseApplyAndFlyApplyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.airspaceFlight.domain.ReleaseFlyApply;
import com.ruoyi.airspaceFlight.service.IReleaseFlyApplyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 放飞申请Controller
 * 
 * @author ruoyi
 * @date 2023-11-06
 */
@RestController
@RequestMapping("/releasefly")
public class ReleaseFlyApplyController extends BaseController
{
    @Autowired
    private IReleaseFlyApplyService releaseFlyApplyService;

    /**
     * 查询放飞申请列表
     */
//    @RequiresPermissions("airspaceFlight:apply:list")
    @PostMapping ("/list")
    public TableDataInfo list(@RequestBody ReleaseFlyApply releaseFlyApply)
    {
        startPage();
        List<ReleaseApplyAndFlyApplyVo> list = releaseFlyApplyService.selectReleaseFlyApplyList(releaseFlyApply);
        return getDataTable(list);
    }

//    /**
//     * 导出放飞申请列表
//     */
//    @RequiresPermissions("airspaceFlight:apply:export")
//    @Log(title = "放飞申请", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ReleaseFlyApply releaseFlyApply)
//    {
//        List<ReleaseApplyAndFlyApplyVo> list = releaseFlyApplyService.selectReleaseFlyApplyList(releaseFlyApply);
//        ExcelUtil<ReleaseFlyApply> util = new ExcelUtil<ReleaseFlyApply>(ReleaseFlyApply.class);
//        util.exportExcel(response, list, "放飞申请数据");
//    }

    /**
     * 获取放飞申请详细信息
     */
    @RequiresPermissions("airspaceFlight:apply:query")
    @GetMapping(value = "/{releaseApplyId}")
    public AjaxResult getInfo(@PathVariable("releaseApplyId") String releaseApplyId)
    {
        return AjaxResult.success(releaseFlyApplyService.selectReleaseFlyApplyByReleaseApplyId(releaseApplyId));
    }

    /**
     * 新增放飞申请
     */
    @RequiresPermissions("airspaceFlight:apply:add")
    @Log(title = "放飞申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add( ReleaseFlyApply releaseFlyApply)
    {
        return toAjax(releaseFlyApplyService.insertReleaseFlyApply(releaseFlyApply));
    }

    /**
     * 修改放飞申请
     */
//    @RequiresPermissions("airspaceFlight:apply:edit")
    @Log(title = "放飞申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReleaseFlyApply releaseFlyApply)
    {
        return toAjax(releaseFlyApplyService.updateReleaseFlyApply(releaseFlyApply));
    }

    /**
     * 批量审批
     */
//    @RequiresPermissions("airspaceFlight:apply:edit")
    @Log(title = "放飞申请", businessType = BusinessType.UPDATE)
    @PutMapping("/updates")
    public AjaxResult edits(@RequestBody List<ReleaseFlyApply> releaseFlyApplys)
    {
        return toAjax(releaseFlyApplyService.updateReleaseFlyApplys(releaseFlyApplys));
    }

    /**
     * 删除放飞申请
     */
    @RequiresPermissions("airspaceFlight:apply:remove")
    @Log(title = "放飞申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{releaseApplyIds}")
    public AjaxResult remove(@PathVariable String[] releaseApplyIds)
    {
        return toAjax(releaseFlyApplyService.deleteReleaseFlyApplyByReleaseApplyIds(releaseApplyIds));
    }
}
